Skip to content

fix(json): quote object keys in schema output#1023

Open
CastawayEGR wants to merge 2 commits intortk-ai:developfrom
CastawayEGR:fix/json-unquoted-keys-v2
Open

fix(json): quote object keys in schema output#1023
CastawayEGR wants to merge 2 commits intortk-ai:developfrom
CastawayEGR:fix/json-unquoted-keys-v2

Conversation

@CastawayEGR
Copy link
Copy Markdown

Object keys in compact_json() and extract_schema() were missing double quotes, producing invalid JSON that breaks jq, python3 json.load(), etc.

Wraps all key formatting in "key": instead of key:.

Fixes #1015

Both functions formatted JSON object keys without double quotes,
producing invalid JSON that broke jq, python json.load(), etc.

Fixes rtk-ai#1015
@pszymkowiak pszymkowiak added bug Something isn't working effort-small Quelques heures, 1 fichier labels Apr 4, 2026
@pszymkowiak
Copy link
Copy Markdown
Collaborator

[w] wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes invalid JSON output from compact_json() and extract_schema() by wrapping object keys in double quotes. Previously, keys were emitted without quotes, breaking standard JSON parsers like jq and Python's json.load().

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Linked issues: #1015


Analyzed automatically by wshm · This is an automated analysis, not a human review.

Copy link
Copy Markdown
Contributor

@em0t em0t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this locally against current master and this branch, and I still see blocking issues before merge.

First, rtk json <file> still does not produce valid JSON for object output because object entries are not comma-separated, so jq and python -c 'import json,sys; json.load(sys.stdin)' still fail on simple cases.

Second, keys are wrapped in quotes but not escaped, so inputs containing " or \ in object keys still produce invalid output.

I also don’t think --schema currently satisfies the “valid JSON” claim, because tokens like int, string, and [int] (3) are not JSON values.

I’d either narrow the PR description to “quote keys in display output” or extend the implementation/tests to cover actual JSON-valid output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working effort-small Quelques heures, 1 fichier

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants